﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OracleClient;
namespace BLL.Sec
{
    /// <summary>
    /// 单位类
    /// </summary>
    public class Unit
    {
        private readonly OracleDAL.Sec.Unit dal = new OracleDAL.Sec.Unit();
        /// <summary>
        /// 单位构造函数
        /// </summary>
        public Unit()
        {
        }
        #region 删除单位，静态方法和实例方法
        /// <summary>
        /// 删除单位
        /// </summary>
        /// <param name="UnitISN">单位ISN</param>
        /// <returns>删除是否成功</returns>
        public  bool DeleteUnit(string UnitISN)
        {
            return dal.DeleteUnit(UnitISN);
        }
        /// <summary>
        /// 删除单位
        /// </summary>
        /// <param name="unit">单位对象</param>
        /// <returns>删除是否成功</returns>
        public  bool DeleteUnit(Model.Sec.Unit unit)
        {
            return dal.DeleteUnit(unit.UnitISN);
        }
        #endregion
        /// <summary>
        /// 判断数据是否存在
        /// </summary>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public bool exist(string strWhere)
        {
            return dal.exist(strWhere);
        }
        public Model.Sec.Unit GetModelBYWhere(string strWhere)
        {
            return dal.GetModelBYWhere(strWhere);

        }
        /// <summary>
        /// 移动相邻单位
        /// </summary>
        /// <param name="upNodeid"></param>
        /// <param name="i"></param>
        /// <returns></returns>
        public bool moveUnit(string upNodeid, int i)
        {
            return dal.moveUnit(upNodeid, i);
        }
        /// <summary>
        /// 返回记录数
        /// </summary>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public int getCount(string strWhere)
        {
            return dal.getCount(strWhere);
        }
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public bool del(string strWhere)
        {
            return dal.DelBYWhere(strWhere);
        }
        /// <summary>
        /// 更新全部字段
        /// </summary>
        /// <param name="unit"></param>
        /// <returns></returns>
        public bool update(Model.Sec.Unit unit)
        {
            return dal.Update(unit);
        }
        /// <summary>
        /// 增加全部字段
        /// </summary>
        /// <param name="unit"></param>
        /// <returns></returns>
        public bool add(Model.Sec.Unit unit)
        {
            return dal.addUnit(unit);
        }
        public List<Model.Sec.Unit> GetAll(string unitisn)
        {
            return dal.GetAll(unitisn);
        }
        /// <summary>
        /// 返回OracleDataReader,因为数据太多了
        /// </summary>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public OracleDataReader returnDataReader(string strWhere)
        {
            return dal.returnDataReader(strWhere);
        }
         /// <summary>
        /// 返回单位ISN和单位名称,和上级NodeID
        /// </summary>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public DataTable getTable(string strWhere)
        {
            return dal.getTable(strWhere);
        }
    }
}